<script setup>
/**
 * 应用入口布局组件：
 * - 顶部导航栏 Navbar
 * - 路由视图 RouterView（主要内容）
 * - 横幅 flower-catalog-banner：仅在非 hideBanner 路由显示
 * - 页脚
 * 关键点：
 * - 基于路由元信息 meta.hideBanner 控制横幅显示
 * - 横幅采用 16:9 背景图，居中定位
 */
import { RouterView } from 'vue-router'
import Navbar from './components/Navbar.vue'
import { useRoute } from 'vue-router'
import { computed } from 'vue'

const route = useRoute()
const showBanner = computed(() => !route.meta?.hideBanner)
</script>

<template>
  <div id="app" class="app-container">
    <!-- 使用抽象的导航栏组件 -->
    <Navbar />
    
    
    <!-- 花卉目录横幅 -->
    <section v-if="showBanner" class="flower-catalog-banner">
      <div class="banner-content">
        <h1 class="banner-title">把春天，搬进生活里</h1>
        <p class="banner-subtitle">当季限定花束低至6折，满99元免运费</p>
        <div class="banner-tag"></div>
      </div>
    </section>

    <!-- 主要内容区域 -->
    <main class="main-content">
      <RouterView />
    </main>
    
    <!-- 页脚 -->
    <footer class="app-footer">
      <div class="footer-content">
        <div class="footer-links">
          <a href="#" class="footer-link">关于我们</a>
          <a href="#" class="footer-link">帮助中心</a>
          <a href="#" class="footer-link">联系我们</a>
        </div>
        <p class="copyright">版权所有信息·隐私政策·接纳未成年人就业信息·沪ICP备 沪公备信息:15355590673</p>
      </div>
    </footer>
  </div>
</template>

<style scoped>
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background: white;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo-container {
  display: flex;
  align-items: center;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  color: #333;
}

.logo-text {
  font-size: 24px;
  font-weight: 700;
  color: #333;
}

.logo-bell {
  font-size: 18px;
  color: #333;
}

.main-nav {
  display: flex;
  gap: 30px;
}

.nav-link {
  color: #666;
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
  padding: 10px 0;
  position: relative;
  transition: color 0.3s ease;
}

.nav-link:hover {
  color: #8E8C41;
}

.nav-link.active {
  color: #8E8C41;
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: #8E8C41;
  border-radius: 3px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

.search-icon-container {
  cursor: pointer;
  padding: 8px;
  color: #666;
}

.search-icon {
  color: #666;
}

.cart-container {
  position: relative;
  cursor: pointer;
  padding: 8px;
  color: #666;
}

.cart-icon {
  color: #666;
  font-size: 18px;
  transition: color 0.3s;
}

.cart-container:hover .cart-icon {
  color: #8E8C41;
}

.cart-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: #ff6b6b;
  color: white;
  font-size: 0.7rem;
  font-weight: bold;
  padding: 0.15rem 0.4rem;
  border-radius: 50%;
  min-width: 1.2rem;
  text-align: center;
  transform: translate(50%, -50%);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 15px;
  background: #f8fafc;
  border-radius: 25px;
  transition: all 0.3s ease;
}

.user-profile:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #8E8C41;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

.user-name {
  font-size: 14px;
  font-weight: 500;
  color: #333;
}

.logout-button {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logout-button:hover {
  background: #e2e8f0;
  color: #666;
}

.login-button {
  padding: 8px 16px;
  background: #8E8C41;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.login-button:hover {
  background-color: #7A7835;
}

.main-content {
  flex: 1;
  padding: 40px 20px;
}

/* 花卉目录横幅 */
.flower-catalog-banner {
  position: relative;
  width: 100%;
  /* 自适配 16:9 的图片比例，避免被裁切变形 */
  aspect-ratio: 16 / 9;
  height: auto;
  min-height: 320px;
  max-height: 560px;
  background-image: url('./背景.jpg');
  background-size: cover;
  /* 该图片主体在下方，选择 bottom center 提升可见 */
  background-position: center 70%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  margin: 0;
  overflow: hidden;
}

/* 横幅标题全局样式（桌面端） */
.banner-title {
  color: #ffffff;
  font-size: 80px;
  font-weight: 800;
  line-height: 1.1;
  margin: 0 0 12px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.banner-subtitle {
  color: #ffffff;
  font-size: 25px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  
}

.flower-catalog-banner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: transparent;
  z-index: 1;
}

.app-footer {
  background: white;
  border-top: 1px solid #e2e8f0;
  padding: 20px 0;
  margin-top: auto;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  text-align: center;
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 10px;
}

.footer-link {
  color: #666;
  font-size: 14px;
  text-decoration: none;
  transition: color 0.3s ease;
}

.footer-link:hover {
  color: #8E8C41;
}

.copyright {
  color: #999;
  font-size: 12px;
  margin: 0;
  line-height: 1.4;
}

@media (max-width: 768px) {
  .header-content {
    padding: 0 15px;
  }
  
  .main-nav {
    display: none;
  }
  
  .search-container {
    display: none;
  }
  
  .logo-text {
    font-size: 20px;
  }
  
  .user-name {
    display: none;
  }
  
  .main-content {
    padding: 20px 15px;
  }
  
  .banner-title {
    font-size: 100px;
    color: #ffffff;
  }
  
  .quick-categories {
    flex-direction: column;
    gap: 20px;
  }
  
  .category-item {
    width: 100%;
  }
  
  .flower-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .knowledge-content {
    flex-direction: column;
  }
  
  .knowledge-image {
    width: 100%;
    min-width: auto;
    height: 200px;
  }
}
</style>
